<?php
header('Content-Type:text/html;charset=utf-8');
require('../..//public/zscg.php');
require('../..//public/local.php');
$uname=$_POST['uname'];
$opwd=$_POST['opwd'];
$npwd=$_POST['npwd'];
$pwd=$_POST['pwd'];
$res1=select($con,'user','where `nicheng` = "'.$uname.'"')[0];
if($res1['password'] != $opwd){
    echo "<script>alert('原密码输入错误');window.location.href='/admin/password/index.php'</script>";
    die;
}
if($npwd != $pwd){
    echo "<script>alert('两次输入的密码不相同');window.location.href='/admin/password/index.php'</script>";
    die;
}
$arr=array('password' => $pwd);
$res2=update($con,'user',$res1['id'],$arr);
if($res2){
    echo "<script>window.location.href='/admin/password/ok.php'</script>";
}else{
    echo "<script>alert('修改失败');window.location.href='/admin/password/index.php'</script>";
}